function [B_allsol,max_Ck_indx] = gen_lo_hi(eta, B_in,data,indUnc)

% External Variables
Vs   = data(:,1);
Gold = data(:,2);

% Parameter
NQ = size(B_in,3);

% Solve B
parfor iii = 1:NQ
    
    % rotate and normalize B
    B_est= B_in(:,:,iii);
    ehat = eta(:,:)*inv(B_est)';
    
    % Compute Correlations
   %phi1 = corr(Vs, ehat(:,1));
    phi2 = corr(Vs, ehat(:,indUnc));
   %phi1_gold = corr(Gold, ehat(:,1));
    phi2_gold = corr(Gold, ehat(:,indUnc));
    
   %C_est = sqrt(phi2.^2 + phi1_gold.^2);
    
    % Winnowing constraint
    ind_ef(iii) = 1;
    
    B_store(:,:,iii) = B_est;
   %c_store(iii,:) = [phi1,phi2,phi1_gold,phi2_gold,C_est];
    
    G_temp = [0 - phi2, phi2_gold- 0];
    G_sr(iii) = sqrt(G_temp*G_temp');
    
end

B_allsol = B_store(:,:,logical(ind_ef));

% Max G solution
% It returns the max-G result that satisfy winnowing contraint
[~,max_Ck_indx] = max(G_sr(logical(ind_ef)));
%ehat_maxG = eta*inv(B_allsol(:,:,max_Ck_indx))';
end